ga.view.input
Class CamDragListener

java.lang.Object
  extended by ga.view.interfaces.MouseListener
      extended by ga.view.input.CamDragListener
All Implemented Interfaces:
com.jme3.input.controls.ActionListener, com.jme3.input.controls.AnalogListener, com.jme3.input.controls.InputListener

public class CamDragListener
extends MouseListener
implements com.jme3.input.controls.AnalogListener

This is a mouse listener for dragging the camera around the target point.

Since:
12.08.2012
Author:
Stephan Dreyer

Field Summary
private  com.jme3.renderer.Camera cam
           
private  boolean canRotate
           
private  float distance
           
private  com.jme3.input.InputManager inputManager
           
private static java.util.logging.Logger LOGGER
           
private  com.jme3.math.Vector3f lookAt
           
private  float maxDistance
           
private  float maxVRotation
           
private  float minDistance
           
private  float minVRotation
           
private  float rotation
           
private  float rotationSpeed
           
private  float vRotation
           
private  float zoomSpeed
           
 
Constructor Summary
CamDragListener(com.jme3.renderer.Camera cam, com.jme3.input.InputManager inputManager, CameraSettings camSettings)
          Instantiates a new cam drag listener.
 
Method Summary
 void init()
          Inits the class.
 void init(CameraSettings camSettings)
          Initializes the listener using the cam settings.
 void onAction(java.lang.String name, boolean keyPressed, boolean isDoubleClick, float tpf)
          Callback method for mouse events.
 void onAnalog(java.lang.String name, float value, float tpf)
           
 void rotateCamera(float value)
          Rotates the camera around the target on the horizontal plane.
protected  void updateCamera()
          Update the camera, should only be called internally.
 void vRotateCamera(float value)
          Rotates the camera around the target on the vertical plane.
private  void zoomCamera(float value)
          Moves the camera toward or away the target.
 
Methods inherited from class ga.view.interfaces.MouseListener
isEnabled, onAction, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

canRotate

private boolean canRotate

zoomSpeed

private final float zoomSpeed
See Also:
Constant Field Values

rotationSpeed

private final float rotationSpeed
See Also:
Constant Field Values

minVRotation

private float minVRotation

maxVRotation

private float maxVRotation

minDistance

private float minDistance

maxDistance

private float maxDistance

lookAt

private com.jme3.math.Vector3f lookAt

distance

private float distance

rotation

private float rotation

vRotation

private float vRotation

cam

private final com.jme3.renderer.Camera cam

inputManager

private final com.jme3.input.InputManager inputManager
Constructor Detail

CamDragListener

public CamDragListener(com.jme3.renderer.Camera cam,
                       com.jme3.input.InputManager inputManager,
                       CameraSettings camSettings)
Instantiates a new cam drag listener.

Parameters:
cam - the cam
inputManager - the input manager
camSettings - the cam settings
Since:
12.08.2012
Method Detail

init

public void init(CameraSettings camSettings)
Initializes the listener using the cam settings.

Parameters:
camSettings - the cam settings
Since:
12.08.2012

init

public void init()
Inits the class.

Since:
12.08.2012

rotateCamera

public void rotateCamera(float value)
Rotates the camera around the target on the horizontal plane.

Parameters:
value - The amount of rotation.
Since:
12.08.2012

zoomCamera

private void zoomCamera(float value)
Moves the camera toward or away the target.

Parameters:
value - Amount of zoom.
Since:
12.08.2012

vRotateCamera

public void vRotateCamera(float value)
Rotates the camera around the target on the vertical plane.

Parameters:
value - The amount of rotation.
Since:
12.08.2012

updateCamera

protected void updateCamera()
Update the camera, should only be called internally.


onAction

public void onAction(java.lang.String name,
                     boolean keyPressed,
                     boolean isDoubleClick,
                     float tpf)
Description copied from class: MouseListener
Callback method for mouse events. Subclasses must implement this to add custom code.

Specified by:
onAction in class MouseListener
Parameters:
name - Name of the action.
keyPressed - true if the key is still pressed.
isDoubleClick - true if it is a double click.
tpf - The time per frame.

onAnalog

public void onAnalog(java.lang.String name,
                     float value,
                     float tpf)
Specified by:
onAnalog in interface com.jme3.input.controls.AnalogListener